package com.xiyu.service.repository.office.area;

import com.xiyu.service.model.office.area.OfficeAreaClass;
import com.xiyu.service.model.office.area.OfficeAreaClassTable;
import com.xiyu.service.vo.area.officeAreaClass.OfficeAreaClassPageQueryInput;
import org.babyfish.jimmer.spring.repository.JRepository;
import org.babyfish.jimmer.Page;

import java.util.List;

public interface OfficeAreaClassRepository extends JRepository<OfficeAreaClass, Long> {
    OfficeAreaClassTable officeAreaClassTable = OfficeAreaClassTable.$;

    default Page<OfficeAreaClass> pageQuery(OfficeAreaClassPageQueryInput inputVO){
        return
            sql().createQuery(officeAreaClassTable)
            .where(officeAreaClassTable.name().likeIf(inputVO.getName()))
            .select(officeAreaClassTable)
            .fetchPage(inputVO.getPageNo() - 1, inputVO.getPageSize());
    }

    default List<OfficeAreaClass> listQuery(){
        return sql().createQuery(officeAreaClassTable)
                .orderBy(officeAreaClassTable.id().desc())
                .select(officeAreaClassTable).execute();
    }


}